package war2100.editor.menu.handler;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import war2100.Editor;

public class MapHandler implements ActionListener {
	private Editor editor;
	private int type;
	public final static int TYPE_ADDCOLUMN 		= 0;
	public final static int TYPE_REMOVECOLUMN 	= 1;
	public final static int TYPE_ADDLINE 		= 2;
	public final static int TYPE_REMOVELINE 	= 3;

	public MapHandler(Editor editor, int type) {
		this.editor = editor;
		this.type = type;
	}

	@Override
	public void actionPerformed(ActionEvent arg0) {
			
		switch (type) {
		case TYPE_ADDCOLUMN:
			editor.getMap().addColumn(editor.getCurrentTile());
                        editor.getMapDisplay().setMap(editor.getMapDisplay().getMap());
			break;
		case TYPE_REMOVECOLUMN:
			editor.getMap().removeColumn();
                        editor.getMapDisplay().setMap(editor.getMapDisplay().getMap());
			break;
		case TYPE_ADDLINE:
			editor.getMap().addLine(editor.getCurrentTile());
                        editor.getMapDisplay().setMap(editor.getMapDisplay().getMap());
			break;
		case TYPE_REMOVELINE:
			editor.getMap().removeLine();
                        editor.getMapDisplay().setMap(editor.getMapDisplay().getMap());
			break;
		}
		
		editor.repaint();
	}

}
